package com.albert.eurekaproducer.controller;

import com.albert.eurekaproducer.config.AccessToken;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RestController
public class APIController {
    private final static Logger logger = LoggerFactory.getLogger(APIController.class);

    @RequestMapping(value = "/hello")
    @AccessToken
    public String helloWorld(@RequestParam String name) {
        try {
            logger.info("hello api receive msg {} ", name);
            return "hello " + name + ",this is producer";
        } catch (Exception e) {
            logger.error("producer exception ,e={} , ", e.getMessage(), e);
        }
        return "";
    }

    @RequestMapping(value = "/gogogo")
    public String gogogo(@RequestBody Object jsonstr) {
        try {
            logger.info("gogogo api receive msg {} ", jsonstr);
            return "hello ,this is gogogo";
        } catch (Exception e) {
            logger.error("gogogo exception ,e={} , ", e.getMessage(), e);
        }
        return "";
    }
}
